/*
 * Copyright (C) 2009 Otávio Scherer Garcia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.technorati4j.entity;

import org.jdom.Element;

import com.googlecode.technorati4j.util.StringUtils;

/**
 * Request entity for bloginfo API.
 * 
 * @author Otávio Scherer Garcia
 * @version $Revision$
 */
public final class BlogInfoResponse
    implements Response {

    /**
     * The URL parameter.
     */
    private String url;

    /**
     * The weblog.
     */
    private Weblog weblog;

    /**
     * The number of unbound blogs.
     */
    private Integer inboundBlogs;

    /**
     * The number of unbound links.
     */
    private Integer inboundLinks;

    public BlogInfoResponse(Element element) {
        element = element.getChild("result");
        url = element.getChildTextTrim("url");
        inboundBlogs = StringUtils.toInteger(element.getChildTextTrim("inboundblogs"));
        inboundLinks = StringUtils.toInteger(element.getChildTextTrim("inboundlinks"));
        weblog = new Weblog(element.getChild("weblog"));
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Weblog getWeblog() {
        return weblog;
    }

    public void setWeblog(Weblog weblog) {
        this.weblog = weblog;
    }

    public Integer getInboundBlogs() {
        return inboundBlogs;
    }

    public void setInboundBlogs(Integer inboundBlogs) {
        this.inboundBlogs = inboundBlogs;
    }

    public Integer getInboundLinks() {
        return inboundLinks;
    }

    public void setInboundLinks(Integer inboundLinks) {
        this.inboundLinks = inboundLinks;
    }

    @Override
    public String toString() {
        final StringBuilder str = new StringBuilder();
        str.append("url=");
        str.append(url);
        str.append("&weblog=");
        str.append(weblog);
        str.append("&inboundBlogs=");
        str.append(inboundBlogs);
        str.append("&inboundLinks=");
        str.append(inboundLinks);

        return str.toString();
    }

}
